package com.struts2.action;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Restrictions;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.struts2.model.Category;
import com.struts2.model.Color;
import com.struts2.model.Customer;
import com.struts2.model.Designer;
import com.struts2.model.Gender;
import com.struts2.model.Product_item;
import com.struts2.model.Product_line;
import com.struts2.model.Season;
import com.struts2.model.Size;
import com.struts2.model.Type;
import com.struts2.service.AdminService;

public class AdminCustomerAction extends ActionSupport implements
		ModelDriven<List<Customer>> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	private List<Customer> customers;

	private Customer customer;
	private int id;

	private String name;
	private String address;
	private String gender;
	private String email;
	private int phone_number;

	public String execute() {

		AdminService as = new AdminService();
		customers = as.getCustomers();
		return "1";
	}

	public String edit() {
		AdminService as = new AdminService();
		customer = as.getCustomer(id);

		return SUCCESS;
	}

	public String save() {
		AdminService as = new AdminService();
		as.setCustomer(id, name, address, gender, email, phone_number);

		customers = as.getCustomers();
		
		

		return SUCCESS;
	}

	@Override
	public List<Customer> getModel() {
		// TODO Auto-generated method stub
		return customers;
	}



	// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////


	public List<Customer> getCustomers() {
		return customers;
	}

	public void setCustomers(List<Customer> customers) {
		this.customers = customers;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getPhone_number() {
		return phone_number;
	}

	public void setPhone_number(int phone_number) {
		this.phone_number = phone_number;
	}

	
	// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}
